import pandas as pd

wD = pd.read_excel('测风数据2.0（完整）杨明海&焦志雄 .xlsx',parse_dates=['Date & Time Stamp'])
den = 1.041
#print(wD['Date & Time Stamp'].dt.month)

wD['hour']=wD['Date & Time Stamp'].dt.hour
#monthDay={'1时':31,'2时':28,'3时':31,'4时':30,'5时':31,'6时':30,'7时':31,'8时':31,'9时':30,'10时':31,'11时':30,'12时':31}
hourAvgWV={'0时':0,'1时':0,'2时':0,'3时':0,'4时':0,'5时':0,'6时':0,'7时':0,'8时':0,'9时':0,'10时':0,'11时':0,'12时':0,
           '13时':0,'14时':0,'15时':0,'16时':0,'17时':0,'18时':0,'19时':0,'20时':0,'21时':0,'22时':0,'23时':0}
hourAvgWPD={'0时':0,'1时':0,'2时':0,'3时':0,'4时':0,'5时':0,'6时':0,'7时':0,'8时':0,'9时':0,'10时':0,'11时':0,'12时':0,
           '13时':0,'14时':0,'15时':0,'16时':0,'17时':0,'18时':0,'19时':0,'20时':0,'21时':0,'22时':0,'23时':0}

n=0
for hour in wD['hour']:
    h=str(hour)+'时'
    hourAvgWV[h]+=wD['CH2Avg'][n:n+1].values
    hourAvgWPD[h]+=1/2*den*(wD['CH1Avg'][n:n+1].values)**3
    #print(wD['CH1Avg'][n:n+1])
    n+=1
    #wD['month'][n]=m

for hour in hourAvgWV:
    hourAvgWV[hour] = format(float(hourAvgWV[hour]/2190),'.3f')
    hourAvgWPD[hour] = format(float(hourAvgWPD[hour]/2190),'.3f')
    print(hour,'平均风速:',hourAvgWV[hour])
    print(hour,'平均风功率密度:',hourAvgWPD[hour])

print(type(hourAvgWV['1时']))
#print(hourAvgWV)

#print(wD['Date & Time Stamp'][2]) 

